<?php // On démarre la session (ceci est indispensable dans toutes les pages)
session_start();
$login = isset($_POST['login']) ? $_POST['login'] : "rien";
$disconnect = isset($_GET['disconnect']) ? $_GET['disconnect'] : "false";
$cnx = isset($_GET['connexionFail']) ? $_GET['connexionFail'] : "false";

if ($disconnect === "true") {
	// On détruit les variables de notre session
	session_unset();

	// On détruit notre session
	session_destroy();

}

// On récupère nos variables de session
$pwd = isset($_POST['pwd']) ? $_POST['pwd'] : 'nada';
$connect = "FALSE";

if ($login != '' && $pwd != '') {
	include_once "phpClass/metier/importClass.php";
	$profil = McsProfile::get($login);

	if ($profil != null) {
		if ($profil -> getPROFILEDESCR() === $pwd) {  // test password...
			$_SESSION['login'] = $login;
			$connect = "TRUE";
		}
		else {
			header("Status: 301 Moved Permanently", false, 301);
			header('Location: login.php?connexionFail=TRUE');
			exit();		
		}

	}
}

 if ($connect==="TRUE") {
	header("Status: 301 Moved Permanently", false, 301);
	header('Location: index.php?loginPage=TRUE');
	exit();		
 	
} 
?>

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Login page</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta name="description" content="">
		<meta name="author" content="">

		<!--	Le styles	-->
		<link rel="stylesheet" href="jquery.mobile-1.3.1/jquery.mobile-1.3.1.min.css" />

		<link rel="stylesheet" href="jquery.mobile-1.3.1/demos/css/themes/default/jquery.mobile-1.3.1.css" />
		<link rel="stylesheet" href="themes/MandC-Theme.css" />
		<link rel="stylesheet" href="css/login.css" />
		<link rel="stylesheet" href="css/index.css" />

		<!-- Javascript
		<script src="js/main.js"></script>
		<!--<script src="jquery.mobile-1.3.1/jquery.mobile-1.3.1.min.js"></script>
		<script src="jquery.mobile-1.3.1/demos/js/jquery.js"></script>
		<script src="jquery.mobile-1.3.1/demos/js/jquery.mobile-1.3.1.js"></script>-->

	</head>

	<body>

		<div data-role="page" data-theme="a" >

			<!--<div data-theme="a" data-role="header" data-position="fixed">
				<h1>SPACE M&C</h1>
			</div>
-->
			<form class="form-signin" action="login.php" method="POST">
				<h2 class="form-signin-heading">Entrez votre login / mot de passe</h2>

				<div data-role="fieldcontain" >
					<input id="login" name="login" type="text" data-clear-btn="true" class="input-block-level" placeholder="login">
				</div>
				<div data-role="fieldcontain" >
					<input id="pwd" name="pwd" type="password" data-clear-btn="true" class="input-block-level" placeholder="mot de passe">
				</div>

				<button data-theme="b" type="submit" class="btn btn-large btn-primary">
					Connexion
				</button>
			</form>


			
			<?php

			if ($cnx === "true") {								
				echo "<div id='error'><p id='message'>Login ou mot de passe incorrect</p></div>";
			}

			?>

		<!--	<div data-theme="b" data-role="footer" data-position="fixed">
				<div data-role="navbar">
					<ul>
						<li>
							<a href="">Alarms</a>
						</li>
						<li>
							<a href="">Logs</a>
						</li>
						<li>
							<a href="">Statistics</a>
						</li>
					</ul>
				</div>
		</div>-->
			
		</div>

	</body>
</html>
>